classdef DCmotorControl3L < matlab.apps.AppBase

    % Properties that correspond to app components
    properties (Access = public)
        UIFigure                       matlab.ui.Figure
        MisceLogo                      matlab.ui.control.Image
        Competence                     matlab.ui.control.Label
        DCMotorControlLabel            matlab.ui.control.Label
        ConnecttoplatformLabel         matlab.ui.control.Label
        aSelecttheserialportLabel      matlab.ui.control.Label
        bPushConnectLabel              matlab.ui.control.Label
        cConnectionstateLabel          matlab.ui.control.Label
        AvailableportsListBox          matlab.ui.control.ListBox
        AvailableportsListBoxLabel     matlab.ui.control.Label
        ConnectButton                  matlab.ui.control.Button
        StateLabel                     matlab.ui.control.Label
        DisconnectexitButton           matlab.ui.control.Button
        TabGroup                       matlab.ui.container.TabGroup
        MotorwarmupTab1                matlab.ui.container.Tab
        labeleTime1                    matlab.ui.control.Label
        comment101                     matlab.ui.control.Label
        comment102                     matlab.ui.control.Label
        eTime1                         matlab.ui.control.NumericEditField
        execute1                       matlab.ui.control.Button
        OpenloopresponseTab2           matlab.ui.container.Tab
        comment201                     matlab.ui.control.Label
        comment202                     matlab.ui.control.Label
        inputRef2                      matlab.ui.control.NumericEditField
        TiempodeensayosLabel_4         matlab.ui.control.Label
        eTime2                         matlab.ui.control.NumericEditField
        execute2                       matlab.ui.control.Button
        saveResults2                   matlab.ui.control.Button
        TiempodeensayosLabel_3         matlab.ui.control.Label
        figure2                        matlab.ui.control.UIAxes
        VelocityControlactionsTab3     matlab.ui.container.Tab
        comment301                     matlab.ui.control.Label
        comment302                     matlab.ui.control.Label
        TiempodeensayosLabel_6         matlab.ui.control.Label
        execute3                       matlab.ui.control.Button
        Kd3                            matlab.ui.control.NumericEditField
        Ki3                            matlab.ui.control.NumericEditField
        Kp3                            matlab.ui.control.NumericEditField
        inputRef3                      matlab.ui.control.NumericEditField
        eTime3                         matlab.ui.control.NumericEditField
        controllerLabel3               matlab.ui.control.Label
        controllerEq3                  matlab.ui.control.Label
        labelKp3                       matlab.ui.control.Label
        labelKi3                       matlab.ui.control.Label
        labelKd3                       matlab.ui.control.Label
        TiempodeensayosLabel_9         matlab.ui.control.Label
        TiempodeensayosLabel_8         matlab.ui.control.Label
        TiempodeensayosLabel_7         matlab.ui.control.Label
        TiempodeensayosLabel_5         matlab.ui.control.Label
        saveResults3                   matlab.ui.control.Button
        figure3                        matlab.ui.control.UIAxes
        VelocityControlzerospolesTab4  matlab.ui.container.Tab
        comment401                     matlab.ui.control.Label
        execute4                       matlab.ui.control.Button
        Pi4                            matlab.ui.control.NumericEditField
        Ci4                            matlab.ui.control.NumericEditField
        P4                             matlab.ui.control.NumericEditField
        C4                             matlab.ui.control.NumericEditField
        K4                             matlab.ui.control.NumericEditField
        inputRef4                      matlab.ui.control.NumericEditField
        eTime4                         matlab.ui.control.NumericEditField
        controllerLabel4               matlab.ui.control.Label
        controllerEq4                  matlab.ui.control.Label
        labelK4                        matlab.ui.control.Label
        labelC4                        matlab.ui.control.Label
        labelP4                        matlab.ui.control.Label
        labelCi4                       matlab.ui.control.Label
        labelPi4                       matlab.ui.control.Label
        TiempodeensayosLabel_32        matlab.ui.control.Label
        TiempodeensayosLabel_31        matlab.ui.control.Label
        TiempodeensayosLabel_30        matlab.ui.control.Label
        TiempodeensayosLabel_29        matlab.ui.control.Label
        TiempodeensayosLabel_28        matlab.ui.control.Label
        TiempodeensayosLabel_25        matlab.ui.control.Label
        TiempodeensayosLabel_14        matlab.ui.control.Label
        saveResults4                   matlab.ui.control.Button
        figure4                        matlab.ui.control.UIAxes
        PositionControlactionsTab5     matlab.ui.container.Tab
        comment501                     matlab.ui.control.Label
        comment502                     matlab.ui.control.Label
        execute5                       matlab.ui.control.Button
        Kd5                            matlab.ui.control.NumericEditField
        Ki5                            matlab.ui.control.NumericEditField
        Kp5                            matlab.ui.control.NumericEditField
        inputRef5                      matlab.ui.control.NumericEditField
        eTime5                         matlab.ui.control.NumericEditField
        controllerLabel5               matlab.ui.control.Label
        controllerEq5                  matlab.ui.control.Label
        labelKp5                       matlab.ui.control.Label
        labelKi5                       matlab.ui.control.Label
        labelKd5                       matlab.ui.control.Label
        TiempodeensayosLabel_45        matlab.ui.control.Label
        TiempodeensayosLabel_44        matlab.ui.control.Label
        TiempodeensayosLabel_43        matlab.ui.control.Label
        saveResults5                   matlab.ui.control.Button
        TiempodeensayosLabel_26        matlab.ui.control.Label
        TiempodeensayosLabel_19        matlab.ui.control.Label
        figure5                        matlab.ui.control.UIAxes
        PositionControlzerospolesTab6  matlab.ui.container.Tab
        comment601                     matlab.ui.control.Label
        execute6                       matlab.ui.control.Button
        Pi6                            matlab.ui.control.NumericEditField
        Ci6                            matlab.ui.control.NumericEditField
        P6                             matlab.ui.control.NumericEditField
        C6                             matlab.ui.control.NumericEditField
        K6                             matlab.ui.control.NumericEditField
        inputRef6                      matlab.ui.control.NumericEditField
        eTime6                         matlab.ui.control.NumericEditField
        controllerLabel6               matlab.ui.control.Label
        controllerEq6                  matlab.ui.control.Label
        labelK6                        matlab.ui.control.Label
        labelC6                        matlab.ui.control.Label
        labelP6                        matlab.ui.control.Label
        labelCi6                       matlab.ui.control.Label
        labelPi6                       matlab.ui.control.Label
        TiempodeensayosLabel_50        matlab.ui.control.Label
        TiempodeensayosLabel_49        matlab.ui.control.Label
        TiempodeensayosLabel_48        matlab.ui.control.Label
        TiempodeensayosLabel_47        matlab.ui.control.Label
        TiempodeensayosLabel_46        matlab.ui.control.Label
        TiempodeensayosLabel_37        matlab.ui.control.Label
        saveResults6                   matlab.ui.control.Button
        TiempodeensayosLabel_36        matlab.ui.control.Label
        figure6                        matlab.ui.control.UIAxes
    end

    properties (Access = private)
        sp 
        output 
        time 
        voltage 
        t
        experiment % Matrix of results
    end

    % Callbacks that handle component events
    methods (Access = private)

        % Code that executes after component creation
        function startupFcn(app)
            app.ConnectButton.Visible=true;
            app.aSelecttheserialportLabel.Visible = true;
            app.bPushConnectLabel.Visible = true;
            app.cConnectionstateLabel.Visible=true;
            app.StateLabel.Visible=true;
            app.AvailableportsListBox.Visible=true;
            app.AvailableportsListBox.Items=serialportlist('available');
            app.StateLabel.Text='Disconnected';
            app.execute1.Enable = 'off';
            app.execute2.Enable = 'off';
            app.execute3.Enable = 'off';
            app.execute4.Enable = 'off';
            app.execute5.Enable = 'off';
            app.execute6.Enable = 'off';

        end

        % Button pushed function: ConnectButton
        function ConnectButtonPushed(app, event)
            %funcion para conectar con arduino
            puerto_com= app.AvailableportsListBox.Value;
            app.StateLabel.Text='Connecting...';
            try
                app.sp = serialport(puerto_com,115200,'Timeout',11);
                fopen(app.sp);
                fprintf(app.sp,'%i\n',1); 
                connection_read= fscanf(app.sp,'%i');
                if connection_read == 1 
                    app.StateLabel.Text='Connected';
                    app.execute1.Enable = 'on';
                    app.execute2.Enable = 'on';
                    app.execute3.Enable = 'on';
                    app.execute4.Enable = 'on';
                    app.execute5.Enable = 'on';
                    app.execute6.Enable = 'on';
                else
                    app.StateLabel.Text='Not possible to connect';

                end
            catch
                app.StateLabel.Text='Not possible to connect';
                warning('Not possible to connect to the serial port')
            end
        end

        % Button pushed function: DisconnectexitButton
        function DisconnectexitButtonPushed(app, event)
            delete(app);          
        end

        % Button pushed function: execute1
        function execute1Pushed(app, event)
            flush(app.sp); operationMode = 1;
            tsim=abs(app.eTime1.Value);
            fprintf(app.sp,'%i\n',operationMode);
            fprintf(app.sp,'%i\n',tsim);
            try
                warmupFlag = fscanf(app.sp,'%i');
            catch
                warning('Some data lost');
            end
        end

        % Button pushed function: execute2
        function execute2Pushed(app, event)
            % Operation mode 2: Open loop for identification
            flush(app.sp); operationMode = 2;
            tsim=abs(app.eTime2.Value);
            v=app.inputRef2.Value;
            u=v*255/12;
            fprintf(app.sp,'%i\n',operationMode);
            fprintf(app.sp,'%f\n',u);
            fprintf(app.sp,'%i\n',tsim);
            app.output=[];
            app.time=[];
            app.voltage=[];
            app.t=0;
            while app.t<tsim
                dato_salida  = fscanf(app.sp,'%f');
                dato_tiempo  = fscanf(app.sp,'%f');
                dato_tension = fscanf(app.sp,'%f');
                app.output=[app.output dato_salida];
                app.time=[app.time dato_tiempo];
                app.voltage=[app.voltage dato_tension*12/255];                    
                app.t=dato_tiempo;
            end
            app.output = app.output;
            output_filt=sgolayfilt(app.output,1,13);
            app.experiment=[app.time; app.voltage; app.output; output_filt];
            k= mean(output_filt(end-20:end));
            app.figure2.Visible=true;
            plot(app.figure2,app.time,output_filt,'b');
            xlabel(app.figure2,'t(s)');ylabel(app.figure2,'\omega (rad/s)');
       
        end

        % Button pushed function: execute3
        function execute3Pushed(app, event)
            % Operation mode 3: Velocity control (actions)
            flush(app.sp); operationMode = 3;
            tsim = abs(app.eTime3.Value);
            vref = app.inputRef3.Value;
            kp   = app.Kp3.Value;
            ki   = app.Ki3.Value;
            kd   = app.Kd3.Value;
            fprintf(app.sp,'%i\n',operationMode);
            fprintf(app.sp,'%f\n',vref);
            fprintf(app.sp,'%i\n',tsim);
            fprintf(app.sp,'%f\n',kp);
            fprintf(app.sp,'%f\n',ki);
            fprintf(app.sp,'%f\n',kd);
            app.output=[];
            app.time=[];
            app.voltage=[];
            app.t=0;
            while app.t<tsim
                dato_salida=fscanf(app.sp,'%f');
                dato_tiempo=fscanf(app.sp,'%f');
                dato_tension=fscanf(app.sp,'%f');
                app.output=[app.output dato_salida];
                app.time=[app.time dato_tiempo];
                app.voltage=[app.voltage dato_tension*12/255]; 
                app.t=dato_tiempo;
            end
            
            salida_filt=sgolayfilt(app.output,1,13);
            app.experiment=[app.time; app.voltage; app.output; salida_filt];
            app.figure3.Visible=true;
            plot(app.figure3,app.time,vref*ones(1,length(app.output)),app.time,salida_filt);
            xlabel(app.figure3,'t(s)');ylabel(app.figure3,'\omega(rpm)');
            legend(app.figure3,'\omega_{ref}(t)','\omega(t)','location','best');
        end

        % Button pushed function: execute4
        function execute4Pushed(app, event)
            % Operation mode 5: Velocity control (zeros/poles)
            flush(app.sp); operationMode = 4;
            tsim=abs(app.eTime4.Value);
            vref= app.inputRef4.Value;
            k = app.K4.Value;
            c =  app.C4.Value;
            p =   app.P4.Value;
            c_i = app.Ci4.Value;
            p_i = app.Pi4.Value;

            fprintf(app.sp,'%i\n',operationMode);
            fprintf(app.sp,'%f\n',vref);
            fprintf(app.sp,'%i\n',tsim);
            fprintf(app.sp,'%f\n',k);
            fprintf(app.sp,'%f\n',c);
            fprintf(app.sp,'%f\n',p);
            fprintf(app.sp,'%f\n',c_i);
            fprintf(app.sp,'%f\n',p_i);
            app.output=[];
            app.time=[];
            app.voltage=[];
            app.t=0;
            while app.t<tsim
                dato_salida=fscanf(app.sp,'%f');
                dato_tiempo=fscanf(app.sp,'%f');
                dato_tension=fscanf(app.sp,'%f');
                app.output=[app.output dato_salida];
                app.time=[app.time dato_tiempo];
                app.voltage=[app.voltage dato_tension*12/255];
                app.t=dato_tiempo;               
            end
            salida_filt=sgolayfilt(app.output,1,7);
            app.experiment=[app.time; app.voltage; app.output; salida_filt];
            app.figure4.Visible=true;
            plot(app.figure4,app.time,vref*ones(1,length(app.output)),app.time,salida_filt);
            xlabel(app.figure4,'t(s)'); ylabel(app.figure4,'\omega(rpm)');
            legend(app.figure4,'\omega_{ref}','\omega(t)','location','best');
        end

        % Button pushed function: execute5
        function execute5Pushed(app, event)
            % Operation mode 5: Position control (actions)
            flush(app.sp); operationMode = 5;
            tsim=abs(app.eTime5.Value);
            pref=app.inputRef5.Value;
            kp = app.Kp5.Value;
            kd = app.Kd5.Value;
            ki = app.Ki5.Value;
            fopen(app.sp);
            fprintf(app.sp,'%i\n',operationMode);
            fprintf(app.sp,'%f\n',pref);
            fprintf(app.sp,'%i\n',tsim);
            fprintf(app.sp,'%f\n',kp);
            fprintf(app.sp,'%f\n',kd);
            fprintf(app.sp,'%f\n',ki);
            app.output=[];
            app.time=[];
            app.voltage=[];
            app.t=0;
            while app.t<tsim
                dato_salida=fscanf(app.sp,'%f');
                dato_tiempo=fscanf(app.sp,'%f');
                dato_tension=fscanf(app.sp,'%f');
                app.output=[app.output dato_salida];
                app.time=[app.time dato_tiempo];
                app.voltage=[app.voltage dato_tension*12/255]; 
                app.t=dato_tiempo;
            end
            salida_filt=sgolayfilt(app.output,1,7);
            app.experiment=[app.time; app.voltage; app.output; salida_filt];
            app.figure5.Visible=true;
            plot(app.figure5,app.time,app.output,'-b',app.time,salida_filt,'-r',app.time,pref*ones(1,length(app.output)),'--r');
            xlabel(app.figure5,'t(s)');ylabel(app.figure5,'\theta(rad)');
            legend(app.figure5,'\theta(t)','\theta(t)_{filt}','\theta_{ref}','location','best');
        end

        % Button pushed function: execute6
        function execute6Pushed(app, event)
            % Operation mode 6: Position control (zeros/poles)
            flush(app.sp); operationMode = 6;
            tsim=abs(app.eTime6.Value);  pref= (app.inputRef6.Value); 
            k = app.K6.Value;
            c = app.C6.Value;
            p = app.P6.Value;
            c_i = app.Ci6.Value;
            p_i = app.Pi6.Value;
            
            fprintf(app.sp,'%i\n',operationMode);
            fprintf(app.sp,'%f\n',pref);
            fprintf(app.sp,'%i\n',tsim);
            fprintf(app.sp,'%f\n',k);
            fprintf(app.sp,'%f\n',c);
            fprintf(app.sp,'%f\n',p);
            fprintf(app.sp,'%f\n',c_i);
            fprintf(app.sp,'%f\n',p_i);
            app.output=[];
            app.time=[];
            app.voltage=[];
            app.t=0;
            while app.t<tsim
                dato_salida=fscanf(app.sp,'%f');
                dato_tiempo=fscanf(app.sp,'%f');
                dato_tension=fscanf(app.sp,'%f');
                app.output=[app.output dato_salida];
                app.time=[app.time dato_tiempo];
                app.voltage=[app.voltage dato_tension*12/255];
                app.t=dato_tiempo;               
            end
            
            salida_filt=sgolayfilt(app.output,1,7);
            app.experiment=[app.time; app.voltage; app.output; salida_filt];
            app.figure6.Visible=true;
            xlabel(app.figure6,'t(s)');ylabel(app.figure6,'\theta(rad)');
            plot(app.figure6,app.time,app.output,'-b',app.time,salida_filt,'-r',app.time,pref*ones(1,length(app.output)),'--r');
            legend(app.figure6,'\theta(t)','\theta(t)_{filt}','\theta_{ref}','location','best');
        end

        % Button pushed function: saveResults2
        function saveResults2Pushed(app, event)
            try
                [fn,pn]=uiputfile('*.txt');
                fname = [pn fn];
                fileID=fopen(fname,"w");
                fprintf(fileID,'%f %f %f %f\n',app.experiment);
                fclose(fileID);
            catch
                warning('The results have not been saved');
            end
            
        end

        % Button pushed function: saveResults3
        function saveResults3Pushed(app, event)
            try
                [fn,pn]=uiputfile('*.txt');
                fname = [pn fn];
                fileID=fopen(fname,"w");
                fprintf(fileID,'%f %f %f %f\n',app.experiment);
                fclose(fileID);
            catch
                warning('The results have not been saved');
            end
            
        end

        % Button pushed function: saveResults4
        function saveResults4Pushed(app, event)
            try
                [fn,pn]=uiputfile('*.txt');
                fname = [pn fn];
                fileID=fopen(fname,"w");
                fprintf(fileID,'%f %f %f %f\n',app.experiment);
                fclose(fileID);
            catch
                warning('The results have not been saved');
            end
            
        end

        % Button pushed function: saveResults5
        function saveResults5Pushed(app, event)
            try
                [fn,pn]=uiputfile('*.txt');
                fname = [pn fn];
                fileID=fopen(fname,"w");
                fprintf(fileID,'%f %f %f %f\n',app.experiment);
                fclose(fileID);
            catch
                warning('The results have not been saved');
            end
            
        end

        % Button pushed function: saveResults6
        function saveResults6Pushed(app, event)
            try
                [fn,pn]=uiputfile('*.txt');
                fname = [pn fn];
                fileID=fopen(fname,"w");
                fprintf(fileID,'%f %f %f %f\n',app.experiment);
                fclose(fileID);
            catch
                warning('The results have not been saved');
            end
            
        end
    end

    % Component initialization
    methods (Access = private)

        % Create UIFigure and components
        function createComponents(app)

            % Get the file path for locating images
            pathToMLAPP = fileparts(mfilename('fullpath'));

            % Create UIFigure and hide until all components are created
            app.UIFigure = uifigure('Visible', 'off');
            app.UIFigure.Position = [100 100 1162 672];
            app.UIFigure.Name = 'MATLAB App';

            % Create TabGroup
            app.TabGroup = uitabgroup(app.UIFigure);
            app.TabGroup.Position = [16 26 1141 390];

            % Create MotorwarmupTab1
            app.MotorwarmupTab1 = uitab(app.TabGroup);
            app.MotorwarmupTab1.Title = 'Motor warm up';

            % Create execute1
            app.execute1 = uibutton(app.MotorwarmupTab1, 'push');
            app.execute1.ButtonPushedFcn = createCallbackFcn(app, @execute1Pushed, true);
            app.execute1.FontColor = [0 0.4471 0.7412];
            app.execute1.Position = [283 299 100 23];
            app.execute1.Text = 'Warm up';

            % Create eTime1
            app.eTime1 = uieditfield(app.MotorwarmupTab1, 'numeric');
            app.eTime1.Position = [322 334 58 22];
            app.eTime1.Value = 10;

            % Create comment102
            app.comment102 = uilabel(app.MotorwarmupTab1);
            app.comment102.FontAngle = 'italic';
            app.comment102.FontColor = [0 0.4471 0.7412];
            app.comment102.Position = [15 227 344 29];
            app.comment102.Text = 'Warming up the motor aids to obtain homogenous results.';

            % Create comment101
            app.comment101 = uilabel(app.MotorwarmupTab1);
            app.comment101.FontAngle = 'italic';
            app.comment101.FontColor = [0 0.4471 0.7412];
            app.comment101.Position = [15 247 387 30];
            app.comment101.Text = 'Some dynamics parameters of the motor change with the temperature.';

            % Create labeleTime1
            app.labeleTime1 = uilabel(app.MotorwarmupTab1);
            app.labeleTime1.Position = [16 334 100 22];
            app.labeleTime1.Text = 'Warm up time (s):';

            % Create OpenloopresponseTab2
            app.OpenloopresponseTab2 = uitab(app.TabGroup);
            app.OpenloopresponseTab2.Title = 'Open loop response';

            % Create figure2
            app.figure2 = uiaxes(app.OpenloopresponseTab2);
            title(app.figure2, 'Open loop experiment')
            xlabel(app.figure2, 't(s)')
            ylabel(app.figure2, 'velocity (rad/s)')
            zlabel(app.figure2, 'Z')
            app.figure2.Box = 'on';
            app.figure2.XGrid = 'on';
            app.figure2.YGrid = 'on';
            app.figure2.Position = [592 60 531 294];

            % Create TiempodeensayosLabel_3
            app.TiempodeensayosLabel_3 = uilabel(app.OpenloopresponseTab2);
            app.TiempodeensayosLabel_3.Position = [15 334 112 22];
            app.TiempodeensayosLabel_3.Text = 'Experiment time (s):';

            % Create saveResults2
            app.saveResults2 = uibutton(app.OpenloopresponseTab2, 'push');
            app.saveResults2.ButtonPushedFcn = createCallbackFcn(app, @saveResults2Pushed, true);
            app.saveResults2.FontColor = [0 0.4471 0.7412];
            app.saveResults2.Position = [624 28 494 23];
            app.saveResults2.Text = 'Save open loop results';

            % Create execute2
            app.execute2 = uibutton(app.OpenloopresponseTab2, 'push');
            app.execute2.ButtonPushedFcn = createCallbackFcn(app, @execute2Pushed, true);
            app.execute2.FontColor = [0 0.4471 0.7412];
            app.execute2.Position = [283 273 100 23];
            app.execute2.Text = 'Execute';

            % Create eTime2
            app.eTime2 = uieditfield(app.OpenloopresponseTab2, 'numeric');
            app.eTime2.Position = [325 334 58 22];
            app.eTime2.Value = 3;

            % Create TiempodeensayosLabel_4
            app.TiempodeensayosLabel_4 = uilabel(app.OpenloopresponseTab2);
            app.TiempodeensayosLabel_4.Position = [15 307 135 22];
            app.TiempodeensayosLabel_4.Text = 'Input Voltage (-12,12) V:';

            % Create inputRef2
            app.inputRef2 = uieditfield(app.OpenloopresponseTab2, 'numeric');
            app.inputRef2.Position = [325 307 58 22];
            app.inputRef2.Value = 10;

            % Create comment202
            app.comment202 = uilabel(app.OpenloopresponseTab2);
            app.comment202.FontAngle = 'italic';
            app.comment202.FontColor = [0 0.4471 0.7412];
            app.comment202.Position = [16 210 344 29];
            app.comment202.Text = 'identify the transfer function of the DC- motor';

            % Create comment201
            app.comment201 = uilabel(app.OpenloopresponseTab2);
            app.comment201.FontAngle = 'italic';
            app.comment201.FontColor = [0 0.4471 0.7412];
            app.comment201.Position = [16 229 380 30];
            app.comment201.Text = 'Exciting the motor with several values input voltage allows to ';

            % Create VelocityControlactionsTab3
            app.VelocityControlactionsTab3 = uitab(app.TabGroup);
            app.VelocityControlactionsTab3.Title = 'Velocity Control (actions)';

            % Create figure3
            app.figure3 = uiaxes(app.VelocityControlactionsTab3);
            title(app.figure3, 'Velocity control experiment')
            xlabel(app.figure3, 't(s)')
            ylabel(app.figure3, 'velocity (rad/s)')
            zlabel(app.figure3, 'Z')
            app.figure3.Box = 'on';
            app.figure3.XGrid = 'on';
            app.figure3.YGrid = 'on';
            app.figure3.Position = [592 60 531 294];

            % Create saveResults3
            app.saveResults3 = uibutton(app.VelocityControlactionsTab3, 'push');
            app.saveResults3.ButtonPushedFcn = createCallbackFcn(app, @saveResults3Pushed, true);
            app.saveResults3.FontColor = [0 0.4471 0.7412];
            app.saveResults3.Position = [624 28 494 23];
            app.saveResults3.Text = 'Save velocity control results';

            % Create TiempodeensayosLabel_5
            app.TiempodeensayosLabel_5 = uilabel(app.VelocityControlactionsTab3);
            app.TiempodeensayosLabel_5.Position = [15 334 112 22];
            app.TiempodeensayosLabel_5.Text = 'Experiment time (s):';

            % Create TiempodeensayosLabel_7
            app.TiempodeensayosLabel_7 = uilabel(app.VelocityControlactionsTab3);
            app.TiempodeensayosLabel_7.Position = [14 205 124 22];
            app.TiempodeensayosLabel_7.Text = 'Proporcional constant,';

            % Create TiempodeensayosLabel_8
            app.TiempodeensayosLabel_8 = uilabel(app.VelocityControlactionsTab3);
            app.TiempodeensayosLabel_8.Position = [14 174 97 22];
            app.TiempodeensayosLabel_8.Text = 'Integral constant,';

            % Create TiempodeensayosLabel_9
            app.TiempodeensayosLabel_9 = uilabel(app.VelocityControlactionsTab3);
            app.TiempodeensayosLabel_9.Position = [14 142 110 22];
            app.TiempodeensayosLabel_9.Text = 'Derivative constant,';

            % Create labelKd3
            app.labelKd3 = uilabel(app.VelocityControlactionsTab3);
            app.labelKd3.Interpreter = 'latex';
            app.labelKd3.FontAngle = 'italic';
            app.labelKd3.Position = [152 142 25 22];
            app.labelKd3.Text = '$k_d$';

            % Create labelKi3
            app.labelKi3 = uilabel(app.VelocityControlactionsTab3);
            app.labelKi3.Interpreter = 'latex';
            app.labelKi3.FontAngle = 'italic';
            app.labelKi3.Position = [152 174 25 22];
            app.labelKi3.Text = '$k_i$';

            % Create labelKp3
            app.labelKp3 = uilabel(app.VelocityControlactionsTab3);
            app.labelKp3.Interpreter = 'latex';
            app.labelKp3.FontAngle = 'italic';
            app.labelKp3.Position = [151 205 25 22];
            app.labelKp3.Text = '$k_p$';

            % Create controllerEq3
            app.controllerEq3 = uilabel(app.VelocityControlactionsTab3);
            app.controllerEq3.Interpreter = 'latex';
            app.controllerEq3.BackgroundColor = [0.302 0.7451 0.9333];
            app.controllerEq3.FontSize = 17;
            app.controllerEq3.Position = [143 242 172 51];
            app.controllerEq3.Text = '$R(s)=k_p +\frac{k_i}{s}+k_d · s$';

            % Create controllerLabel3
            app.controllerLabel3 = uilabel(app.VelocityControlactionsTab3);
            app.controllerLabel3.FontWeight = 'bold';
            app.controllerLabel3.Position = [81 254 62 22];
            app.controllerLabel3.Text = 'Controller';

            % Create eTime3
            app.eTime3 = uieditfield(app.VelocityControlactionsTab3, 'numeric');
            app.eTime3.Position = [325 334 58 22];
            app.eTime3.Value = 3;

            % Create inputRef3
            app.inputRef3 = uieditfield(app.VelocityControlactionsTab3, 'numeric');
            app.inputRef3.Position = [325 307 58 22];
            app.inputRef3.Value = 10;

            % Create Kp3
            app.Kp3 = uieditfield(app.VelocityControlactionsTab3, 'numeric');
            app.Kp3.Position = [324 205 58 22];

            % Create Ki3
            app.Ki3 = uieditfield(app.VelocityControlactionsTab3, 'numeric');
            app.Ki3.Position = [324 174 58 22];

            % Create Kd3
            app.Kd3 = uieditfield(app.VelocityControlactionsTab3, 'numeric');
            app.Kd3.Position = [324 142 58 22];

            % Create execute3
            app.execute3 = uibutton(app.VelocityControlactionsTab3, 'push');
            app.execute3.ButtonPushedFcn = createCallbackFcn(app, @execute3Pushed, true);
            app.execute3.FontColor = [0 0.4471 0.7412];
            app.execute3.Position = [283 105 100 23];
            app.execute3.Text = 'Execute';

            % Create TiempodeensayosLabel_6
            app.TiempodeensayosLabel_6 = uilabel(app.VelocityControlactionsTab3);
            app.TiempodeensayosLabel_6.Position = [15 307 142 22];
            app.TiempodeensayosLabel_6.Text = 'Velocity reference (rad/s):';

            % Create comment302
            app.comment302 = uilabel(app.VelocityControlactionsTab3);
            app.comment302.FontAngle = 'italic';
            app.comment302.FontColor = [0 0.4471 0.7412];
            app.comment302.Position = [11 35 466 30];
            app.comment302.Text = 'written in term of the propotional, integral and derivative action';

            % Create comment301
            app.comment301 = uilabel(app.VelocityControlactionsTab3);
            app.comment301.FontAngle = 'italic';
            app.comment301.FontColor = [0 0.4471 0.7412];
            app.comment301.Position = [11 61 466 30];
            app.comment301.Text = 'This operation mode allows you to control the DC-motor by means of a PID controller';

            % Create VelocityControlzerospolesTab4
            app.VelocityControlzerospolesTab4 = uitab(app.TabGroup);
            app.VelocityControlzerospolesTab4.Title = 'Velocity Control (zeros/poles)';

            % Create figure4
            app.figure4 = uiaxes(app.VelocityControlzerospolesTab4);
            title(app.figure4, 'Velocity control experiment')
            xlabel(app.figure4, 't(s)')
            ylabel(app.figure4, 'velocity (rad/s)')
            zlabel(app.figure4, 'Z')
            app.figure4.Box = 'on';
            app.figure4.XGrid = 'on';
            app.figure4.YGrid = 'on';
            app.figure4.Position = [592 60 531 294];

            % Create saveResults4
            app.saveResults4 = uibutton(app.VelocityControlzerospolesTab4, 'push');
            app.saveResults4.ButtonPushedFcn = createCallbackFcn(app, @saveResults4Pushed, true);
            app.saveResults4.FontColor = [0 0.4471 0.7412];
            app.saveResults4.Position = [624 28 494 23];
            app.saveResults4.Text = 'Save velocity control results';

            % Create TiempodeensayosLabel_14
            app.TiempodeensayosLabel_14 = uilabel(app.VelocityControlzerospolesTab4);
            app.TiempodeensayosLabel_14.Position = [15 334 112 22];
            app.TiempodeensayosLabel_14.Text = 'Experiment time (s):';

            % Create TiempodeensayosLabel_25
            app.TiempodeensayosLabel_25 = uilabel(app.VelocityControlzerospolesTab4);
            app.TiempodeensayosLabel_25.Position = [15 307 142 22];
            app.TiempodeensayosLabel_25.Text = 'Velocity reference (rad/s):';

            % Create TiempodeensayosLabel_28
            app.TiempodeensayosLabel_28 = uilabel(app.VelocityControlzerospolesTab4);
            app.TiempodeensayosLabel_28.Position = [14 204 37 22];
            app.TiempodeensayosLabel_28.Text = 'Gain, ';

            % Create TiempodeensayosLabel_29
            app.TiempodeensayosLabel_29 = uilabel(app.VelocityControlzerospolesTab4);
            app.TiempodeensayosLabel_29.Position = [15 173 35 22];
            app.TiempodeensayosLabel_29.Text = 'zero, ';

            % Create TiempodeensayosLabel_30
            app.TiempodeensayosLabel_30 = uilabel(app.VelocityControlzerospolesTab4);
            app.TiempodeensayosLabel_30.Position = [16 141 34 22];
            app.TiempodeensayosLabel_30.Text = 'pole, ';

            % Create TiempodeensayosLabel_31
            app.TiempodeensayosLabel_31 = uilabel(app.VelocityControlzerospolesTab4);
            app.TiempodeensayosLabel_31.Position = [16 109 35 22];
            app.TiempodeensayosLabel_31.Text = 'zero, ';

            % Create TiempodeensayosLabel_32
            app.TiempodeensayosLabel_32 = uilabel(app.VelocityControlzerospolesTab4);
            app.TiempodeensayosLabel_32.Position = [15 72 31 22];
            app.TiempodeensayosLabel_32.Text = 'pole,';

            % Create labelPi4
            app.labelPi4 = uilabel(app.VelocityControlzerospolesTab4);
            app.labelPi4.Interpreter = 'latex';
            app.labelPi4.FontAngle = 'italic';
            app.labelPi4.Position = [82 73 25 22];
            app.labelPi4.Text = '$p_i$';

            % Create labelCi4
            app.labelCi4 = uilabel(app.VelocityControlzerospolesTab4);
            app.labelCi4.Interpreter = 'latex';
            app.labelCi4.FontAngle = 'italic';
            app.labelCi4.Position = [82 105 25 22];
            app.labelCi4.Text = '$c_i$';

            % Create labelP4
            app.labelP4 = uilabel(app.VelocityControlzerospolesTab4);
            app.labelP4.Interpreter = 'latex';
            app.labelP4.FontAngle = 'italic';
            app.labelP4.Position = [82 138 25 22];
            app.labelP4.Text = '$p$';

            % Create labelC4
            app.labelC4 = uilabel(app.VelocityControlzerospolesTab4);
            app.labelC4.Interpreter = 'latex';
            app.labelC4.FontAngle = 'italic';
            app.labelC4.Position = [82 171 25 22];
            app.labelC4.Text = '$c$';

            % Create labelK4
            app.labelK4 = uilabel(app.VelocityControlzerospolesTab4);
            app.labelK4.Interpreter = 'latex';
            app.labelK4.FontAngle = 'italic';
            app.labelK4.Position = [82 204 25 22];
            app.labelK4.Text = '$k$';

            % Create controllerEq4
            app.controllerEq4 = uilabel(app.VelocityControlzerospolesTab4);
            app.controllerEq4.Interpreter = 'latex';
            app.controllerEq4.BackgroundColor = [0.302 0.7451 0.9333];
            app.controllerEq4.FontSize = 17;
            app.controllerEq4.Position = [147 242 175 49];
            app.controllerEq4.Text = '$R(s)=k·\frac{s+c}{s+p}·\frac{s+c_i}{s+p_i} $';

            % Create controllerLabel4
            app.controllerLabel4 = uilabel(app.VelocityControlzerospolesTab4);
            app.controllerLabel4.FontWeight = 'bold';
            app.controllerLabel4.Position = [84 254 62 22];
            app.controllerLabel4.Text = 'Controller';

            % Create eTime4
            app.eTime4 = uieditfield(app.VelocityControlzerospolesTab4, 'numeric');
            app.eTime4.Position = [325 334 58 22];
            app.eTime4.Value = 3;

            % Create inputRef4
            app.inputRef4 = uieditfield(app.VelocityControlzerospolesTab4, 'numeric');
            app.inputRef4.Position = [325 307 58 22];
            app.inputRef4.Value = 10;

            % Create K4
            app.K4 = uieditfield(app.VelocityControlzerospolesTab4, 'numeric');
            app.K4.Position = [324 204 58 22];

            % Create C4
            app.C4 = uieditfield(app.VelocityControlzerospolesTab4, 'numeric');
            app.C4.Position = [324 171 58 22];

            % Create P4
            app.P4 = uieditfield(app.VelocityControlzerospolesTab4, 'numeric');
            app.P4.Position = [324 138 58 22];

            % Create Ci4
            app.Ci4 = uieditfield(app.VelocityControlzerospolesTab4, 'numeric');
            app.Ci4.Position = [324 105 58 22];

            % Create Pi4
            app.Pi4 = uieditfield(app.VelocityControlzerospolesTab4, 'numeric');
            app.Pi4.Position = [324 72 58 22];

            % Create execute4
            app.execute4 = uibutton(app.VelocityControlzerospolesTab4, 'push');
            app.execute4.ButtonPushedFcn = createCallbackFcn(app, @execute4Pushed, true);
            app.execute4.FontColor = [0 0.4471 0.7412];
            app.execute4.Position = [283 39 100 23];
            app.execute4.Text = 'Execute';

            % Create comment401
            app.comment401 = uilabel(app.VelocityControlzerospolesTab4);
            app.comment401.FontAngle = 'italic';
            app.comment401.FontColor = [0 0.4471 0.7412];
            app.comment401.Position = [8 6 618 30];
            app.comment401.Text = 'This operation mode allows you to control the DC-motor by means of a PID controller defining its ceros and poles';

            % Create PositionControlactionsTab5
            app.PositionControlactionsTab5 = uitab(app.TabGroup);
            app.PositionControlactionsTab5.Title = 'Position Control (actions)';

            % Create figure5
            app.figure5 = uiaxes(app.PositionControlactionsTab5);
            title(app.figure5, 'Position control experiment')
            xlabel(app.figure5, 't(s)')
            ylabel(app.figure5, 'position (rad)')
            zlabel(app.figure5, 'Z')
            app.figure5.Box = 'on';
            app.figure5.XGrid = 'on';
            app.figure5.YGrid = 'on';
            app.figure5.Position = [592 60 531 294];

            % Create TiempodeensayosLabel_19
            app.TiempodeensayosLabel_19 = uilabel(app.PositionControlactionsTab5);
            app.TiempodeensayosLabel_19.Position = [15 334 112 22];
            app.TiempodeensayosLabel_19.Text = 'Experiment time (s):';

            % Create TiempodeensayosLabel_26
            app.TiempodeensayosLabel_26 = uilabel(app.PositionControlactionsTab5);
            app.TiempodeensayosLabel_26.Position = [15 307 134 22];
            app.TiempodeensayosLabel_26.Text = 'Position reference (rad):';

            % Create saveResults5
            app.saveResults5 = uibutton(app.PositionControlactionsTab5, 'push');
            app.saveResults5.ButtonPushedFcn = createCallbackFcn(app, @saveResults5Pushed, true);
            app.saveResults5.FontColor = [0 0.4471 0.7412];
            app.saveResults5.Position = [624 28 494 23];
            app.saveResults5.Text = 'Save position control results';

            % Create TiempodeensayosLabel_43
            app.TiempodeensayosLabel_43 = uilabel(app.PositionControlactionsTab5);
            app.TiempodeensayosLabel_43.Position = [14 205 124 22];
            app.TiempodeensayosLabel_43.Text = 'Proporcional constant,';

            % Create TiempodeensayosLabel_44
            app.TiempodeensayosLabel_44 = uilabel(app.PositionControlactionsTab5);
            app.TiempodeensayosLabel_44.Position = [14 174 97 22];
            app.TiempodeensayosLabel_44.Text = 'Integral constant,';

            % Create TiempodeensayosLabel_45
            app.TiempodeensayosLabel_45 = uilabel(app.PositionControlactionsTab5);
            app.TiempodeensayosLabel_45.Position = [14 142 110 22];
            app.TiempodeensayosLabel_45.Text = 'Derivative constant,';

            % Create labelKd5
            app.labelKd5 = uilabel(app.PositionControlactionsTab5);
            app.labelKd5.Interpreter = 'latex';
            app.labelKd5.FontAngle = 'italic';
            app.labelKd5.Position = [152 142 25 22];
            app.labelKd5.Text = '$k_d$';

            % Create labelKi5
            app.labelKi5 = uilabel(app.PositionControlactionsTab5);
            app.labelKi5.Interpreter = 'latex';
            app.labelKi5.FontAngle = 'italic';
            app.labelKi5.Position = [152 174 25 22];
            app.labelKi5.Text = '$k_i$';

            % Create labelKp5
            app.labelKp5 = uilabel(app.PositionControlactionsTab5);
            app.labelKp5.Interpreter = 'latex';
            app.labelKp5.FontAngle = 'italic';
            app.labelKp5.Position = [151 205 25 22];
            app.labelKp5.Text = '$k_p$';

            % Create controllerEq5
            app.controllerEq5 = uilabel(app.PositionControlactionsTab5);
            app.controllerEq5.Interpreter = 'latex';
            app.controllerEq5.BackgroundColor = [0.302 0.7451 0.9333];
            app.controllerEq5.FontSize = 17;
            app.controllerEq5.Position = [143 242 182 51];
            app.controllerEq5.Text = '$R(s)=k_p +k_i·\frac{1}{s}+k_d· s$';

            % Create controllerLabel5
            app.controllerLabel5 = uilabel(app.PositionControlactionsTab5);
            app.controllerLabel5.FontWeight = 'bold';
            app.controllerLabel5.Position = [81 254 62 22];
            app.controllerLabel5.Text = 'Controller';

            % Create eTime5
            app.eTime5 = uieditfield(app.PositionControlactionsTab5, 'numeric');
            app.eTime5.Position = [325 334 58 22];
            app.eTime5.Value = 3;

            % Create inputRef5
            app.inputRef5 = uieditfield(app.PositionControlactionsTab5, 'numeric');
            app.inputRef5.Position = [325 307 58 22];
            app.inputRef5.Value = 10;

            % Create Kp5
            app.Kp5 = uieditfield(app.PositionControlactionsTab5, 'numeric');
            app.Kp5.Position = [324 205 58 22];

            % Create Ki5
            app.Ki5 = uieditfield(app.PositionControlactionsTab5, 'numeric');
            app.Ki5.Position = [324 174 58 22];

            % Create Kd5
            app.Kd5 = uieditfield(app.PositionControlactionsTab5, 'numeric');
            app.Kd5.Position = [324 142 58 22];

            % Create execute5
            app.execute5 = uibutton(app.PositionControlactionsTab5, 'push');
            app.execute5.ButtonPushedFcn = createCallbackFcn(app, @execute5Pushed, true);
            app.execute5.FontColor = [0 0.4471 0.7412];
            app.execute5.Position = [282 105 100 23];
            app.execute5.Text = 'Execute';

            % Create comment502
            app.comment502 = uilabel(app.PositionControlactionsTab5);
            app.comment502.FontAngle = 'italic';
            app.comment502.FontColor = [0 0.4471 0.7412];
            app.comment502.Position = [11 35 466 30];
            app.comment502.Text = 'written in term of the propotional, integral and derivative action';

            % Create comment501
            app.comment501 = uilabel(app.PositionControlactionsTab5);
            app.comment501.FontAngle = 'italic';
            app.comment501.FontColor = [0 0.4471 0.7412];
            app.comment501.Position = [11 61 466 30];
            app.comment501.Text = 'This operation mode allows you to control the DC-motor by means of a PID controller';

            % Create PositionControlzerospolesTab6
            app.PositionControlzerospolesTab6 = uitab(app.TabGroup);
            app.PositionControlzerospolesTab6.Title = 'Position Control (zeros/poles)';

            % Create figure6
            app.figure6 = uiaxes(app.PositionControlzerospolesTab6);
            title(app.figure6, 'Position control experiment')
            xlabel(app.figure6, 't(s)')
            ylabel(app.figure6, 'position (rad)')
            zlabel(app.figure6, 'Z')
            app.figure6.Box = 'on';
            app.figure6.XGrid = 'on';
            app.figure6.YGrid = 'on';
            app.figure6.Position = [592 60 531 294];

            % Create TiempodeensayosLabel_36
            app.TiempodeensayosLabel_36 = uilabel(app.PositionControlzerospolesTab6);
            app.TiempodeensayosLabel_36.Position = [15 334 112 22];
            app.TiempodeensayosLabel_36.Text = 'Experiment time (s):';

            % Create saveResults6
            app.saveResults6 = uibutton(app.PositionControlzerospolesTab6, 'push');
            app.saveResults6.ButtonPushedFcn = createCallbackFcn(app, @saveResults6Pushed, true);
            app.saveResults6.FontColor = [0 0.4471 0.7412];
            app.saveResults6.Position = [624 28 494 23];
            app.saveResults6.Text = 'Save position control results';

            % Create TiempodeensayosLabel_37
            app.TiempodeensayosLabel_37 = uilabel(app.PositionControlzerospolesTab6);
            app.TiempodeensayosLabel_37.Position = [15 307 134 22];
            app.TiempodeensayosLabel_37.Text = 'Position reference (rad):';

            % Create TiempodeensayosLabel_46
            app.TiempodeensayosLabel_46 = uilabel(app.PositionControlzerospolesTab6);
            app.TiempodeensayosLabel_46.Position = [14 204 37 22];
            app.TiempodeensayosLabel_46.Text = 'Gain, ';

            % Create TiempodeensayosLabel_47
            app.TiempodeensayosLabel_47 = uilabel(app.PositionControlzerospolesTab6);
            app.TiempodeensayosLabel_47.Position = [15 173 35 22];
            app.TiempodeensayosLabel_47.Text = 'zero, ';

            % Create TiempodeensayosLabel_48
            app.TiempodeensayosLabel_48 = uilabel(app.PositionControlzerospolesTab6);
            app.TiempodeensayosLabel_48.Position = [16 141 34 22];
            app.TiempodeensayosLabel_48.Text = 'pole, ';

            % Create TiempodeensayosLabel_49
            app.TiempodeensayosLabel_49 = uilabel(app.PositionControlzerospolesTab6);
            app.TiempodeensayosLabel_49.Position = [16 109 35 22];
            app.TiempodeensayosLabel_49.Text = 'zero, ';

            % Create TiempodeensayosLabel_50
            app.TiempodeensayosLabel_50 = uilabel(app.PositionControlzerospolesTab6);
            app.TiempodeensayosLabel_50.Position = [15 72 31 22];
            app.TiempodeensayosLabel_50.Text = 'pole,';

            % Create labelPi6
            app.labelPi6 = uilabel(app.PositionControlzerospolesTab6);
            app.labelPi6.Interpreter = 'latex';
            app.labelPi6.FontAngle = 'italic';
            app.labelPi6.Position = [82 73 25 22];
            app.labelPi6.Text = '$p_i$';

            % Create labelCi6
            app.labelCi6 = uilabel(app.PositionControlzerospolesTab6);
            app.labelCi6.Interpreter = 'latex';
            app.labelCi6.FontAngle = 'italic';
            app.labelCi6.Position = [82 105 25 22];
            app.labelCi6.Text = '$c_i$';

            % Create labelP6
            app.labelP6 = uilabel(app.PositionControlzerospolesTab6);
            app.labelP6.Interpreter = 'latex';
            app.labelP6.FontAngle = 'italic';
            app.labelP6.Position = [82 138 25 22];
            app.labelP6.Text = '$p$';

            % Create labelC6
            app.labelC6 = uilabel(app.PositionControlzerospolesTab6);
            app.labelC6.Interpreter = 'latex';
            app.labelC6.FontAngle = 'italic';
            app.labelC6.Position = [82 171 25 22];
            app.labelC6.Text = '$c$';

            % Create labelK6
            app.labelK6 = uilabel(app.PositionControlzerospolesTab6);
            app.labelK6.Interpreter = 'latex';
            app.labelK6.FontAngle = 'italic';
            app.labelK6.Position = [82 204 25 22];
            app.labelK6.Text = '$k$';

            % Create controllerEq6
            app.controllerEq6 = uilabel(app.PositionControlzerospolesTab6);
            app.controllerEq6.Interpreter = 'latex';
            app.controllerEq6.BackgroundColor = [0.302 0.7451 0.9333];
            app.controllerEq6.FontSize = 17;
            app.controllerEq6.Position = [144 240 175 51];
            app.controllerEq6.Text = '$R(s)=k·\frac{s+c}{s+p}· \frac{s+c_i}{s+p_i}$';

            % Create controllerLabel6
            app.controllerLabel6 = uilabel(app.PositionControlzerospolesTab6);
            app.controllerLabel6.FontWeight = 'bold';
            app.controllerLabel6.Position = [81 254 62 22];
            app.controllerLabel6.Text = 'Controller';

            % Create eTime6
            app.eTime6 = uieditfield(app.PositionControlzerospolesTab6, 'numeric');
            app.eTime6.Position = [325 334 58 22];
            app.eTime6.Value = 3;

            % Create inputRef6
            app.inputRef6 = uieditfield(app.PositionControlzerospolesTab6, 'numeric');
            app.inputRef6.Position = [325 307 58 22];
            app.inputRef6.Value = 10;

            % Create K6
            app.K6 = uieditfield(app.PositionControlzerospolesTab6, 'numeric');
            app.K6.Position = [324 204 58 22];

            % Create C6
            app.C6 = uieditfield(app.PositionControlzerospolesTab6, 'numeric');
            app.C6.Position = [324 171 58 22];

            % Create P6
            app.P6 = uieditfield(app.PositionControlzerospolesTab6, 'numeric');
            app.P6.Position = [324 138 58 22];

            % Create Ci6
            app.Ci6 = uieditfield(app.PositionControlzerospolesTab6, 'numeric');
            app.Ci6.Position = [324 105 58 22];

            % Create Pi6
            app.Pi6 = uieditfield(app.PositionControlzerospolesTab6, 'numeric');
            app.Pi6.Position = [324 72 58 22];

            % Create execute6
            app.execute6 = uibutton(app.PositionControlzerospolesTab6, 'push');
            app.execute6.ButtonPushedFcn = createCallbackFcn(app, @execute6Pushed, true);
            app.execute6.FontColor = [0 0.4471 0.7412];
            app.execute6.Position = [283 39 100 23];
            app.execute6.Text = 'Execute';

            % Create comment601
            app.comment601 = uilabel(app.PositionControlzerospolesTab6);
            app.comment601.FontAngle = 'italic';
            app.comment601.FontColor = [0 0.4471 0.7412];
            app.comment601.Position = [8 6 618 30];
            app.comment601.Text = 'This operation mode allows you to control the DC-motor by means of a PID controller defining its ceros and poles';

            % Create DisconnectexitButton
            app.DisconnectexitButton = uibutton(app.UIFigure, 'push');
            app.DisconnectexitButton.ButtonPushedFcn = createCallbackFcn(app, @DisconnectexitButtonPushed, true);
            app.DisconnectexitButton.FontColor = [1 0 0];
            app.DisconnectexitButton.Position = [1043 465 108 54];
            app.DisconnectexitButton.Text = 'Disconnect & exit';

            % Create StateLabel
            app.StateLabel = uilabel(app.UIFigure);
            app.StateLabel.Position = [424 481 159 22];
            app.StateLabel.Text = 'State';

            % Create ConnectButton
            app.ConnectButton = uibutton(app.UIFigure, 'push');
            app.ConnectButton.ButtonPushedFcn = createCallbackFcn(app, @ConnectButtonPushed, true);
            app.ConnectButton.Position = [279 481 100 23];
            app.ConnectButton.Text = 'Connect';

            % Create AvailableportsListBoxLabel
            app.AvailableportsListBoxLabel = uilabel(app.UIFigure);
            app.AvailableportsListBoxLabel.HorizontalAlignment = 'right';
            app.AvailableportsListBoxLabel.Position = [27 502 84 22];
            app.AvailableportsListBoxLabel.Text = 'Available ports';

            % Create AvailableportsListBox
            app.AvailableportsListBox = uilistbox(app.UIFigure);
            app.AvailableportsListBox.Position = [126 452 100 74];
            app.AvailableportsListBox.Value = 'Item 3';

            % Create cConnectionstateLabel
            app.cConnectionstateLabel = uilabel(app.UIFigure);
            app.cConnectionstateLabel.BackgroundColor = [0.302 0.7451 0.9333];
            app.cConnectionstateLabel.FontWeight = 'bold';
            app.cConnectionstateLabel.Position = [424 534 159 22];
            app.cConnectionstateLabel.Text = 'c. Connection state';

            % Create bPushConnectLabel
            app.bPushConnectLabel = uilabel(app.UIFigure);
            app.bPushConnectLabel.BackgroundColor = [0.302 0.7451 0.9333];
            app.bPushConnectLabel.FontWeight = 'bold';
            app.bPushConnectLabel.Position = [249 534 159 22];
            app.bPushConnectLabel.Text = 'b. Push ''Connect''';

            % Create aSelecttheserialportLabel
            app.aSelecttheserialportLabel = uilabel(app.UIFigure);
            app.aSelecttheserialportLabel.BackgroundColor = [0.302 0.7451 0.9333];
            app.aSelecttheserialportLabel.FontWeight = 'bold';
            app.aSelecttheserialportLabel.Position = [22 534 212 22];
            app.aSelecttheserialportLabel.Text = 'a. Select the serial port';

            % Create ConnecttoplatformLabel
            app.ConnecttoplatformLabel = uilabel(app.UIFigure);
            app.ConnecttoplatformLabel.BackgroundColor = [0 0.4471 0.7412];
            app.ConnecttoplatformLabel.FontColor = [1 1 1];
            app.ConnecttoplatformLabel.Position = [22 561 1130 22];
            app.ConnecttoplatformLabel.Text = '1. Connect to platform';

            % Create DCMotorControlLabel
            app.DCMotorControlLabel = uilabel(app.UIFigure);
            app.DCMotorControlLabel.FontSize = 20;
            app.DCMotorControlLabel.FontWeight = 'bold';
            app.DCMotorControlLabel.FontColor = [0 0.4471 0.7412];
            app.DCMotorControlLabel.Position = [132 607 174 31];
            app.DCMotorControlLabel.Text = 'DC-Motor Control';

            % Create Competence
            app.Competence = uilabel(app.UIFigure);
            app.Competence.FontSize = 24;
            app.Competence.FontWeight = 'bold';
            app.Competence.Position = [132 637 401 32];
            app.Competence.Text = 'Competence: Control Engineering';

            % Create MisceLogo
            app.MisceLogo = uiimage(app.UIFigure);
            app.MisceLogo.Position = [8 591 106 78];
            app.MisceLogo.ImageSource = fullfile(pathToMLAPP, 'logo.png');

            % Show the figure after all components are created
            app.UIFigure.Visible = 'on';
        end
    end

    % App creation and deletion
    methods (Access = public)

        % Construct app
        function app = DCmotorControl3L

            % Create UIFigure and components
            createComponents(app)

            % Register the app with App Designer
            registerApp(app, app.UIFigure)

            % Execute the startup function
            runStartupFcn(app, @startupFcn)

            if nargout == 0
                clear app
            end
        end

        % Code that executes before app deletion
        function delete(app)

            % Delete UIFigure when app is deleted
            delete(app.UIFigure)
        end
    end
end